package net.mihome.app.bean;

import net.mihome.app.AppException;
import net.mihome.app.bean.net.ResponsePojo;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class CommunityList extends Entity{
	private int pageSize;
	private int activeCount;
	private List<Community> list = new ArrayList<Community>();
	
	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getActiveCount() {
		return activeCount;
	}

	public void setActiveCount(int activeCount) {
		this.activeCount = activeCount;
	}

	public List<Community> getList() {
		return list;
	}

	public void setList(List<Community> list) {
		this.list = list;
	}

	public static CommunityList parse(ResponsePojo<Map> responsePojo ) throws IOException, AppException {
		CommunityList communityList = new CommunityList();
		Map dataMap=responsePojo.getData();
		
		List list=(List) dataMap.get("list");
		if(list!=null&&!list.isEmpty()){
			Iterator iterator=list.iterator();
			while(iterator.hasNext()){
				Map map=(Map) iterator.next();
				Community comminuty=Community.parse(map);
				communityList.getList().add(comminuty);
			}
		}
        return communityList;       
	}
    public static CommunityList parseList(ResponsePojo<Map> responsePojo ) {
        CommunityList communityList = new CommunityList();
        Map dataMap=responsePojo.getData();

        List list=(List) dataMap.get("list");
        if(list!=null&&!list.isEmpty()){
            Iterator iterator=list.iterator();
            while(iterator.hasNext()){
                Map map=(Map) iterator.next();
                Community comminuty=Community.parse(map);
                communityList.getList().add(comminuty);
            }
        }
        return communityList;
    }
}
